package handler

import (
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	shop "shop_srv/proto"
	user "user_srv/proto"
)

type ServerInterface interface {
	UserServer(addr *string) user.UserClient
	ShopServer(addr *string) shop.ShopClient
}

type ServerConfig struct {
}

func NewClient() *ServerConfig {
	return &ServerConfig{}
}

func Init(addr *string) *grpc.ClientConn {
	flag.Parse()
	con, _ := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	return con
}

func (c *ServerConfig) UserServer(addr *string) user.UserClient {
	init := Init(addr)
	con := user.NewUserClient(init)
	return con
}

func (c *ServerConfig) ShopServer(addr *string) shop.ShopClient {
	init := Init(addr)
	con := shop.NewShopClient(init)
	return con
}
